<script type="text/javascript" src="<?php echo $url_template?>/js/bootstrap-wysiwyg.js"></script>
<link href="<?php echo $url_template?>/css/bootstrap-wysiwyg.css" rel="stylesheet">
<div class="row-fluid">
<div id="post-body" class="span8">
<h2>Ajouter un nouveau Model Newsletter</h2>
<form name="post"  action="<?php echo $CFG->config['base_url']?>newsletter/admin/edit_news" method="post" id="post"  class="form-inline">
	
		<input type="text" name="fromname" size="30" value="<?php echo $newsletter->fromname?>" placeholder="De: Nom du site"/>
		<input type="text" name="fromemail" size="30" value="<?php echo $newsletter->fromemail?>" placeholder="De: Email du site"/>
		<input type="text" name="subject" size="30" value="<?php echo $newsletter->subject?>" id="title" autocomplete="on" placeholder="Saisissez le sujet ici" />
		<input type="hidden" name="id" size="30" value="<?php echo $newsletter->id?>"/>
		
	 <div class="control-group">
	 	<label for="open" class="control-label" >Contenu </label>
	 	<div class="controls">
			<textarea class="textarea row-fluid"  name="body" id="content"><?php echo $newsletter->body?></textarea>
	   	</div>
	 </div>
	 <div class="controls">
	 
		<input name="save" value="sauvegarder" type="submit" class="btn"/>
		<input name="send" value="Sauvegarder et Envoyer" type="submit" class="btn"/>
		
	  </div>
</form>
		<?php if(!empty($listNewsletter)):?>
		<h3>Archive Newsletter</h3>
			<?php foreach($listNewsletter as $news){?>
		   		 <a href="<?php echo $CFG->config['base_url']?>newsletter/admin/edit/<?php echo $news->id?>"><?php echo $news->subject?></a> <br/> <?php echo date($CFG->config['date_format'],$news->date_create)?>
			<hr/>
			<?php }
		endif;
		?>
</div>


<div class="span4">			
			<table cellspacing="0" class="table">
				<thead>
				<tr>
					<th class="manage-column column-cb check-column" id="cb" scope="col">
						<input type="checkbox" id="cb-select-all-1" class="checkall">
					</th>
					<th class="manage-column column-name" scope="col">
						<span>Email</span><span class="sorting-indicator"></span>
					</th>
				</tr>
				</thead>
			
				<tfoot>
				<tr>
					<th class="manage-column column-cb check-column" id="cb" scope="col">
						<input type="checkbox" id="cb-select-all-1" class="checkall">
					</th>
					<th class="manage-column column-name" scope="col">
						<span>Email</span><span class="sorting-indicator"></span>
					</th>
				</tr>
				</tfoot>
			
				<tbody data-wp-lists="list:tag" id="the-list">
					<?php 
					foreach ($emailList as $idMail=>$email){?>
					<tr class="alternate" id="tag-<?php echo $idMail?>">
						<th scope="row"><input type="checkbox" id="cb-select-all-<?php echo $idMail?>" value="<?php echo $idMail?>"/></th>
						<td class="column-name"><?php echo $email?></td>
						<?php }?>
					</tr>
				</tbody>
			</table>
			<div>
				Page : <?php echo $page?>
			</div>
			
		
		<h3 class='hndle'><span>Ajouter Email</span></h3>
		
		<div class="tagsdiv" id="post_tag">
		<form action="<?php echo $CFG->config['base_url']?>subscribe/admin/addmail" method="post">
				<input name="email" placeholder="email@site.com" type="text"/>
		 		<input type="hidden" name="redirect" value="<?php echo current_url(); ?>" />
				<input name="save" value="ajouter" type="submit"/>
				<p>pour ajouter des emails en même temps, séparé par ,</p>
		</form>
		</div>
		
</div>

</div>
<script type="text/javascript">
$('.textarea').wysihtml5();
function autoTag($divInput){
	var word=$('#title').val().replace(/[^a-zA-Z0-9ãàáäâẽèéëêìíïîõòóöôùúüûñç,.]+/g,' ').split(' ');
	//word=$.unique(word); 
	var uniqueArr = [];
		for (var i = word.length; i--; ) {
            var val = word[i];
            if ($.inArray(val, uniqueArr) === -1) {
                uniqueArr.unshift(val);
            }
        }
	$('#'+$divInput).val(uniqueArr.join(','));
}
</script>
